package cn.school.thoughtworks.section1;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class PracticeB {
    List<String> collectSameElements(List<String> collection1, List<List<String>> collection2) {
        //实现练习要求，并改写该行代码。
        Stream<String> stream = collection1.stream();
        Stream<String> stringStream = stream.filter(collection2.get(0)::contains);
        return stringStream.collect(Collectors.toList());


       /* List list=new ArrayList();
        for(int i=0;i<(collection1.size());i++){
            for(int j=0;j<collection2.get(0).size();j++) {
                if (collection1.get(i) == collection2.get(0).get(j)){
                    list.add(collection1.get(i));
                    //System.out.println(collection1.get(i));
                }
            }
        }
        return list;*/
    }
}
